package com.haulmont.asu.core.listener;

import com.haulmont.asu.entity.DiplomaProject;
import com.haulmont.cuba.core.listener.BeforeInsertEntityListener;
import com.haulmont.cuba.core.listener.BeforeUpdateEntityListener;

/**
 * Author: Sergey42
 * Date: 17.11.13 21:25
 */
public class DiplomaProjectListener implements
        BeforeInsertEntityListener<DiplomaProject>,
        BeforeUpdateEntityListener<DiplomaProject> {

    @Override
    public void onBeforeInsert(DiplomaProject entity) {
        entity.setName(entity.getDiplomaStudent().getStudent().getName() + " - " + entity.getProjectTheme().getName());
    }

    @Override
    public void onBeforeUpdate(DiplomaProject entity) {
        onBeforeInsert(entity);
    }
}
